package com.bdcom.autotest.ui.snp;

import com.bdcom.autotest.util.Prop;
import com.bdcom.autotest.util.UIUtil;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedHashMap;
public class PanelForSetConsoleServer extends AbsPanel {
	public LinkedHashMap<Integer , JTextField> numToPortField = new LinkedHashMap<Integer, JTextField>();
	public PanelForSetConsoleServer() {
		this.setBackground(Color.WHITE);
		this.setPreferredSize(new Dimension( 0 , 250 ));
//		JPanel p1 = UIUtil.createPanel();
		Font font2 = new Font("Dialog",Font.PLAIN, 14);
		JLabel jLabel0 = new JLabel( "tftp服务器地址:");
		jLabel0.setFont(font2);
		JTextField wsn = new JTextField(32);
		wsn.setFont(font2);
		wsn.setText(Prop.tftp_ip);
		wsn.setEnabled(false);
		this.add(jLabel0);
		this.add(wsn);
		this.add(Box.createHorizontalStrut(10) );
		JLabel jLabel1 = new JLabel( "Console服务器地址:");
		jLabel1.setFont(font2);
		JTextField wsn1 = new JTextField(32);
		wsn1.setFont(font2);
		wsn1.setText(Prop.console_server_ip);
		wsn1.setEnabled(false);
		this.add(jLabel1);
		this.add(wsn1);
		for(int i=1; i<9  ;i++  ) {
			String indexStr = ""+(i);
			JLabel jLabel = new JLabel( "端口"+indexStr+":");
			jLabel.setFont(font2);
			JTextField tsn = new JTextField(40);
			tsn.setName(indexStr);
			tsn.setFont(font2);
			tsn.setText(String.valueOf(Prop.console_server_port[i-1]));
			tsn.setEnabled(false);
			this.add(jLabel);
			this.add(tsn);
			this.add(Box.createHorizontalStrut(10) );
			numToPortField.put(i, tsn);
		}


//
//		JPanel p2 = UIUtil.createPanel();
//		JButton btn2 = new JButton("确认");
//		btn2.addActionListener( new ActionListener() {
//			public void actionPerformed(ActionEvent e) {
//				Prop.tftp_ip = wsn.getText();
//				Prop.console_server_ip = wsn1.getText();
//				for(int i=0;i<Prop.console_server_port.length;i++){
//					Prop.console_server_port[i]=Integer.valueOf(numToPortField.get(Integer.valueOf(i+1)).getText());
//				}
//				JOptionPane.showMessageDialog(null, "修改成功！");
//			}
//		});
//		p2.add(Box.createHorizontalStrut( 20 ));
//		p2.add(btn2);
//		this.add(p2);
	}

}
